<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%-- <%@ include file="/adapter/adapter-easyui.jsp" %> --%>
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
<link href="${pageContext.request.contextPath}/frontframe/easyui/themes/easyui-extend.css" rel="stylesheet" type="text/css"/>
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/res/widget/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">

function save(){
	if(!checkData()){
		return false;
	}
	var str_data=$("#noticeinfo input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
    $.ajax({
        url:"${ctx}/appNotice/updateNotice",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
	            window.location.href="${ctx}/auth/appNoticeList?appid=${appid}";
        	}
        },
        error: function() {
          alert("error");
        }
      });
}

function checkData(){
	var siteId=document.getElementById("recordKey").value;
	if(siteId==""){
		alert("系统公告编号不能为空！");
		return false;
	}
	//限制不能输入汉字和非法符号
	var reg=/^[a-zA-Z0-9_]+$/;
	var str=siteId.match(reg);
	if(str==null){
		alert("系统公告编号的数据类型错误！");
		return false;
	}
	var noticeDate=document.getElementById("noticeDate").value;
	var noticeEndDate=document.getElementById("noticeEndDate").value;
	if(noticeDate==null||noticeDate==''||noticeDate==undefined){
		alert("发布日期不能为空");
		return false;
	}
	if(noticeEndDate==null||noticeEndDate==''||noticeEndDate==undefined){
		alert("截止日期不能为空");
		return false;
	}
	var sdate = new Date(noticeDate.replace(/-/g,"/"));
	var edate = new Date(noticeEndDate.replace(/-/g,"/"));
	if(sdate.getTime() > edate.getTime()){
		alert("发布日期不能大于截止日期");
		return false;
	}
	return true;
}

function  goBack(){
	window.history.back(-1);
	//window.history.go(-2);
}
</script>
</head>
<body>
     <div class="panel panel-default">
   <div class="panel-heading">
      <h3 class="panel-title">
          	系统公告
      </h3>
   </div>
   <div class="panel-body">
	<!-- <div id="p" class="easyui-panel" title="交易信息" style="width:100%;height:100%;padding:10px;" > -->
              <form class="form-horizontal" role="form"  id="noticeinfo">
                    
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="recordKey">系统公告编号</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="recordKey" name="recordKey" type="text" readonly="readonly" value="${appNotice.recordKey}"/>
                          </div>  
                          <label class="col-xs-2 control-label" for="appId">移动应用编号</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="appId" name="appId" type="text" readonly="readonly" value="${appNotice.appId}" placeholder=""/>
                          </div>                         
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="noticeTitle">系统公告标题</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="noticeTitle" name="noticeTitle" type="text"   value="${appNotice.noticeTitle}" />
                          </div> 
                          <label class="col-xs-2 control-label" for="noticeContent">系统公告内容</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="noticeContent" name="noticeContent" type="text" value="${appNotice.noticeContent}" />
                          </div>                           
                       </div>
                        <div class="form-group">
                          <label class="col-xs-2 control-label" for="noticeDate">发布时间</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="noticeDate" name="noticeDate" type="text"   value="${appNotice.noticeDate}" placeholder="" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})"/>
                          </div>
                          <label class="col-xs-2 control-label" for="noticeEndDate">截止时间</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="noticeEndDate" name="noticeEndDate" type="text" value="${appNotice.noticeEndDate}"  class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})"/>
                          </div>  
                       </div>
                       
                       <div class="form-group  text-center">
                            <button type="button" class="btn btn-default"  onclick="save();">保存</button>
                            <button type="button" class="btn btn-default"   onclick="goBack()">返回</button>
                      </div>
             </form>
	</div>
	</div>

</body>
</html>
